package com.atguign.gulimall.order.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
@Data
public class OrderConfirmVo {
    List<MemberReceiveAddressEntityVo> address;
    List<OrderItemVo> items;
    Integer integration;
    String orderToken;

    public BigDecimal getTotal() {
        BigDecimal total = new BigDecimal("0");
        if(items != null && !items.isEmpty()){
            for (OrderItemVo item : items) {
                total = total.add(item.getPrice().multiply(BigDecimal.valueOf(item.getCount())));
            }
        }
        return total;
    }

    public Integer getCount() {
        Integer i = 0;
        if(items != null && !items.isEmpty()){
            for (OrderItemVo item : items) {
                i+=item.getCount();
            }
        }
        return i;
    }

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
